#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <functional>
#include <climits>

#define quickio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define endl "\n"

using namespace std;
typedef long long ll;

const int N = 2e5 + 5;

int dp[26 * 2];

void solve()
{
	int n;
	cin >> n;
	string b(n, 0);
	string s(n, 0);
	memset(dp, 0, sizeof(dp));
	unordered_map<int, int>mp;
	char temp[N] = { 0 };
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
		if (dp[b[i] - 'a'] == 0)
		{
			dp[b[i] - 'a'] = 1;
			temp[cnt++] = b[i];
		}
	}
	sort(temp, temp + cnt);
	for (int i = 0; i < cnt; i++)
	{
		mp.insert({ temp[i], temp[cnt - 1 - i] });
	}
	for (int i = 0; i < n; i++)
	{
		s[i] = mp[b[i]];
	}
	cout << s << endl;


	//string s;
	//memset(r, 0, sizeof(r));
	//memset(dp, 0, sizeof(dp));
	//int cnt = 0;
	//for (int i = 0; i < n; i++)
	//{
	//	cin >> s[i];
	//	if (dp[s[i] - 'a'] == 0)
	//	{
	//		dp[s[i] - 'a'] = 1;
	//		r[cnt++] = s[i];
	//	}
	//}
	//sort(r, r + cnt);
	//for (int i = 0; i < n; i++)
	//{
	//	mp.insert(r[i], r[n - 1 - i]);
	//}
	//cout << r << endl;
}

int main()
{
	int t;
	cin >> t;
	while (t--)
		solve();
	return 0;
}